package org.example.myleet.p506;

import java.util.Arrays;

public class Solution {
    public String[] findRelativeRanks(int[] score) {
        String[] labels = new String[]{"Gold Medal", "Silver Medal", "Bronze Medal"};
        int[] map = new int[1000001];
        int[] copyScore = new int[score.length];
        System.arraycopy(score,0, copyScore, 0, score.length);
        Arrays.sort(copyScore);
        int seq = 1;
        for (int i = copyScore.length - 1; i >= 0; --i) {
            map[copyScore[i]] = seq;
            ++seq;
        }
        String[] result = new String[score.length];
        for (int i = 0; i < score.length; ++i) {
            seq = map[score[i]];
            if (seq <= 3) {
                result[i] = labels[seq - 1];
            } else {
                result[i] = seq + "";
            }
        }
        return result;
    }
}
